﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Data.Odbc;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class public_html_NewSite_CMSV2_MasterPage : System.Web.UI.MasterPage
{
    public void Page_Load(object sender, EventArgs e)
    {
        Response.Cache.SetAllowResponseInBrowserHistory(false);
        Response.Cache.SetMaxAge(new TimeSpan(0, 0, 0));

        if (Request.Url.AbsolutePath.ToLowerInvariant().Contains("/metadata/"))
        {
            this.uiAmMenuItems.SelectedIndex = this.uiAmMenuItems.Panes.IndexOf(this.uiApMetadata);
        }
        else
        {
            string page = Request.Url.AbsolutePath.Substring(Request.Url.AbsolutePath.LastIndexOf("/") + 1).ToUpperInvariant();

            if (page.StartsWith("GAME", StringComparison.OrdinalIgnoreCase))
            {
                this.uiAmMenuItems.SelectedIndex = this.uiAmMenuItems.Panes.IndexOf(uiApGames);
            }
            else if (page.StartsWith("REVIEW", StringComparison.OrdinalIgnoreCase))
            {
                this.uiAmMenuItems.SelectedIndex = this.uiAmMenuItems.Panes.IndexOf(this.uiApReview);
            }
            else if (page.StartsWith("NEWS", StringComparison.OrdinalIgnoreCase))
            {
                this.uiAmMenuItems.SelectedIndex = this.uiAmMenuItems.Panes.IndexOf(this.uiApNews);
            }
            else if (page.StartsWith("FRONTPAGE", StringComparison.OrdinalIgnoreCase))
            {
                this.uiAmMenuItems.SelectedIndex = this.uiAmMenuItems.Panes.IndexOf(this.uiApFrontPage);
            }
        }

        this.uiApMetadata.Visible = Page.User.IsInRole("MetadataAdmin");
    }

    protected void Search_Click(object sender, EventArgs e)
    {
        Response.Redirect("GamesList.aspx?Search=" + Server.UrlEncode(uiTxtGameSearch.Text));
    }
}
